﻿using ScFramework.Core;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SRaySword : SFuncBase
{
    public Vector2 Siz;
    public override void ServerKeyDown()
    {
        base.ServerKeyDown();
        CreateEntity("Ray",hasCollision:false);
        Debug.Log("Down");
    
    
    }
    public override void ServerKeyUp()
    {
        base.ServerKeyUp();
        DeleteAllSubEntity();
    }
    public override void SLateFixedUpdate()
    {
        base.SLateFixedUpdate();
        if (subEntityList.Count > 0)

        {
            Debug.Assert(subEntityList.Count == 1);
            foreach (var x in subEntityList)
            {
                
                var r = new SRayVEx(x.GetComponentData<SRay>());
                r.Size = Siz;
                r.LocalRotation = transform.eulerAngles.z;
                r.LocalIsFliped = transform.lossyScale.x < 0;
                r.LocalPosition = transform.position+ transform.right * (Main.ObejectBlockSize/2 + Siz.x / 2);
           //     Debug.Log("rpos="+r.Position);


            }
        }
    }
}